// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
const club = db.collection('club')
// 云函数入口函数
exports.main = async (event, context) => {
  if(event.who==1){
      try {
        return await club.doc(event._id).update({
          data: {
            administrator1: event.openid
          },
        })
        } catch (e) {
          console.error(e)
        }
  } else if (event.who == 2){
      try {
        return await club.doc(event._id).update({
          data: {
            administrator2: event.openid
          },
        })
      } catch (e) {
        console.error(e)
      }
  } else if (event.who == 3) {
    try {
      return await club.doc(event._id).update({
        data: {
          master: event.openid
        },
      })
    } catch (e) {
      console.error(e)
    }
  }

}